﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.SharePoint.Administration;

namespace VH.SharePoint.Api
{
    internal static class SPConstants
    {
        public static String EndPointApi {
            get { return "/_vti_bin/api/blog.ashx"; }
        }

        public static string EndPointRsd
        {
            get { return "/_vti_bin/api/rsd.ashx"; }
        }

        public static string EndPointWlwManifest
        {
            get { return "/_vti_bin/api/wlwmanifest.ashx"; }
        }

        public static string EndPointWlw {
            get { return "/_vti_bin/api/wlw.ashx"; }
        }

        public static string BlogApiSettingsPage {
            get { return "/_layouts/api/blogapisettings.aspx"; }
        }

        public static String BlogMediaLibPB {
            get { return "blog.MediaLibrary"; }
        }

        public static String BlogPostLibPB
        {
            get { return "blog.PostLibrary"; }
        }

        public static String BlogMediaFolderPB
        {
            get { return "blog.MediaFolder"; }
        }

        public static String BlogApiEnabled {
            get { return "blog.Enabled"; }
        }

        public static string BlogScriptTagsEnabled
        {
            get { return "blog.ScriptTagsEnabled"; }
        }

        internal static String DefaultWebConfigOwner {
            get { return "VH.Modules"; }
        }

        internal static SPWebConfigModification BlogHttpModuleWebConfig
        {
            get
            {
                var moduleType = typeof (VH.SharePoint.Api.HttpModules.WeblogUrlRewriter);
                var conf= new SPWebConfigModification("add[@name='" + moduleType.Name + "']","configuration/system.webServer/modules");
                conf.Owner = DefaultWebConfigOwner;
                conf.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
                conf.Sequence = 0;
                conf.Value = "<add name='" + moduleType.Name + "' type='" + moduleType.FullName + ", " + moduleType.Assembly.FullName + "' />";
                return conf;
            }
        }
    }
}
